$EMIVersion = $Null

function Test-EMIClientInstall()
{
    if ($(Test-Path "C:\Inetpub\wwwroot\Incuity\Bin\DataWorks.MI.Core.dll") -eq $false)
    {
        Throw "DataWorks.MI.Core.dll not found. Is EMI Client intalled on this machine?"
    }
    return $True
}


function Load-EMIClientAssemblies()
{
    $CoreAssembly = [System.Reflection.Assembly]::LoadWithPartialName("DataWorks.MI.Core")
    $CoreClientAssembly = [System.Reflection.Assembly]::LoadWithPartialName("DataWorks.MI.Core.Client")
}


# How to get the version of the Incuity System
function Get-EMIVersion()
{
    if( $Script:EMIVersion -eq $Null)
    {
        $Version = [DataWorks.MI.Core.Client.Globals]::Version
    }
    return $Version    
}

function Initialize-EMIClient()
{
    [DataWorks.MI.Core.Client.Globals]::Initialize()
}

$Result = Test-EMIClientInstall
Load-EMIClientAssemblies
$EMIVersion = Get-EMIVersion
Initialize-EMIClient

return $EMIVersion















